
//
//  GTBUmengPushClass.m
//  GuTouBao
//
//  Created by zhaoshijie on 2018/6/26.
//  Copyright © 2018 zhaoshijie. All rights reserved.
//

#import "GTBUmengPushClass.h"

@implementation GTBUmengPushClass


/**
 推送     成交、预警
 
 @param result 推送内容
 */
+ (void)pushApplicationStateActiveWithResult:(NSDictionary *)result
{
    
    //  移除弹框
    [self removeWindowInSubView];
    
    NSString *title = result[@"title"];
    NSString *content = result[@"inContent"];
    
    if(title && content)
    {
        
        /*
        GTBUmengPushView *pushView = [[GTBUmengPushView alloc]initWithTitle:title content:content leftTitle:@"取消" rightTitle:@"查看" closeBlock:nil sureBlock:^{
            
            //  推送消息处理
            [self pushApplicationStateInactiveWithResult:result];
            
        }];
        
        [pushView addToWindow];
         */
        
        
    }
    
}



/**
 推送消息处理
 
 @param result 推送数据
 */
+ (void)pushApplicationStateInactiveWithResult:(NSDictionary *)result
{
    /*
    if(APP_IsExamine)
    {
        return;
    }
    
    
    NSString *title = result[@"title"];
    NSInteger type = [result[@"type"] integerValue];
    NSString *urlString = result[@"url"];
    
    
    switch (type) {
        case 1000:      //  成交
        case 1002:      //  预警
        case 1010:      //  交易
        {
            //  交易界面
            [GTBJumpClass enterInTradeHold];
            break;
        }
        case 1001:      //  止盈
        case 1003:      //  止损
        case 1004:      //  到期平仓
        case 1005:      //  亏损强平
        {
            [GTBJumpClass enterInHistoryTrade];
            
            break;
        }
        case 1006:      //  我的券
        {
            [GTBJumpClass enterInMyselfVoucher];
            
            break;
            
        }
        case 1007:      //  活动
        case 1008:      //  公告、其他
        {
            [GTBJumpClass enterInWebWithTitle:title urlString:urlString];
            
            break;
        }
        case 1009:      //  充值
        {
            
            [GTBJumpClass enterInRecharge];
            
            break;
        }
        case 1011:      //  交易买入
        {
            
            [GTBJumpClass enterInTradeBuy];
            
            break;
        }
        case 1012:      //  自选
        {
            
            [GTBJumpClass enterInOptional];
            
            break;
        }
        case 1013:      //  金股
        {
            
            [GTBJumpClass enterInCommunityToFind];
            
            break;
        }
        case 1014:      //  客服
        {
            
            [GTBJumpClass enterInService];
            
            break;
        }
        case 1015:      //  资金记录
        {
            
            [GTBJumpClass enterInFundHistory];
            
            break;
        }
        case 1016:      //  选股-我的订阅
        {
            
            [GTBJumpClass enterInCommunityToRecommend];
            
            break;
        }
        case 1017:      //  选股-牛人榜
        {
            
            [GTBJumpClass enterInCommunityToRecommend];
            
            break;
        }
        case 1018:      //  选股-今日推荐
        {
            
            [GTBJumpClass enterInCommunityToRecommend];
            
            break;
        }
        case 1019:      //  积分商城
        {
            
            [GTBJumpClass enterInIntegralMall];
            
            break;
        }
        case 1020:      //  新手任务
        {
            
            [GTBJumpClass enterInTask];
            
            break;
        }
        case 1021:      //  喜报
        {
            
            [GTBJumpClass enterInGoodNews];
            
            break;
        }
        case 1022:      //  社区
        {
            
            [GTBJumpClass enterInCommunityToFind];
            
            break;
        }
        case 1023:      //  股票详情
        {
            
            //  数据获取
            
            NSString *sharesCode = result[@"sharesCode"];
            NSString *sharesName = result[@"sharesName"];
            NSString *source = result[@"source"];
            NSInteger susType = [result[@"susType"] integerValue];
            NSInteger shareType = [result[@"shareType"] integerValue];
            
            //  数据组装
            
            GTBSharesModel *model = [[GTBSharesModel alloc]init];
            model.sharesCode = sharesCode;
            model.sharesName = sharesName;
            model.source = source;
            model.susType = @(susType);
            model.shareType = @(shareType);
            
            [GTBJumpClass enterInSharesDetailWithModel:model];
            
            break;
        }
            
        default:
            break;
    }
     */
    
    
}

/**
 app之间的跳转
 
 @param urlSting 跳转的字段
 */
+ (void)jumpApplicationStateActiveWithUrlSting:(NSString *)urlSting
{
    /*
     
    //  xxxx替换了项目跳转的关键字
    
    if([urlSting isEqualToString:@"xxxx://APP_LOGIN"])
    {
        //  登录
        [GTBJumpClass enterInLogin];
        
    }
    else if ([urlSting isEqualToString:@"xxxx://APP_RECHARGE"])
    {
        //  充值
        [GTBJumpClass enterInRecharge];
    }
    else if ([urlSting isEqualToString:@"xxxx://APP_TRADE"])
    {
        //  交易
        [GTBJumpClass enterInTradeHold];
    }
    else if ([urlSting isEqualToString:@"xxxx://APP_BUY"])
    {
        //  买入
        [GTBJumpClass enterInTradeBuy];
    }
    else if ([urlSting isEqualToString:@"xxxx://APP_OPTIONAL"])
    {
        //  自选
        [GTBJumpClass enterInOptional];
    }
    else if ([urlSting isEqualToString:@"xxxx://APP_GOLDENSHARES"])
    {
        //  金股
        [GTBJumpClass enterInCommunityToFind];
    }
    else if ([urlSting isEqualToString:@"xxxx://APP_MYTICKET"])
    {
        //  我的券
        [GTBJumpClass enterInMyselfVoucher];
    }
    else if ([urlSting isEqualToString:@"xxxx://APP_KF"])
    {
        //  客服
        [GTBJumpClass enterInService];
    }
    
    */
    
    
    
}



//  移除弹框
+ (void)removeWindowInSubView
{
    UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
    
    //  移除弹窗
    for (id subView in keyWindow.subviews)
    {
        if([subView isMemberOfClass:[UIView class]])
        {
            UIView *sub = subView;
            [sub removeFromSuperview];
        }
    }
}




@end
